<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>系统设置</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="plugins/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="css/setting/index.css">
	<link rel="stylesheet" href="//at.alicdn.com/t/font_tnyc012u2rlwstt9.css" media="all" />
</head>
<body class="childrenBody">
<div class="layui-tab">
	<ul class="layui-tab-title">
		<li class="layui-this">银行卡设置</li>
		<li>钱包/提现</li>
		<li>繁忙程度设置</li>
		<li>门店介绍</li>
		<li>特价</li>
		<li>评价留言</li>
		<li>提现列表</li>
	</ul>
	<div class="layui-tab-content">

		<div class="layui-tab-item layui-show">
			<form class="layui-form">
			<div class="b-list">
				<ul>
					<li class="show">
						<div class="bank-card">
							<div class="card-left">
								<span id="eduit">+</span>
							</div>
							<div class="card-right">
								<div class="header" id="cardOwner" style="font-size:16px;"></div>
								<p class="number" id="cardNo" style="font-size:18px;"></p>
							</div>
						</div>
					</li>
					<li class="add" id="add">
						<span class="icon-add">+</span>
						<p class="add-bank">点击添加银行卡</p>
					</li>
					<li class="item-edit">
						<div class="header">
							<ul>
								<li>
									<select id="province" class="merchantId" lay-filter="province">
										<option value="">--请选择省份--</option>
									</select>
								</li>
								<li>
									<select id="city" class="merchantId" lay-filter="city">
										<option value="">--请选择城市--</option>
									</select>
								</li>
								<li>
									<select id="district" class="merchantId" lay-filter="district">
										<option value="">--请选择地区--</option>
									</select>
								</li>
								<li>
									<select id="bank" class="merchantId" name="rcvBankNo" lay-verify="required" lay-search>
										<option value="">--请选择支行--</option>
									</select>
								</li>
							</ul>
						</div>
						<div class="content">
							<input type="text" id="bankNumber" placeholder="请输入银行卡号" lay-verify="required" class="bankNumber" name="rcvAcctno" style="width:290px">
							<input type="text" placeholder="请输入开户人" class="bankNumber" lay-verify="required" style="width:290px;" name="rcvAcctName">
						</div>
						<div class="content">
							<div class="left">
								<label id="phone" style="font-size: 25px;"></label>
								<!--<input type="text" placeholder="请输入手机号码" readonly id="phone">-->
								<span id="j_getVerifyCode">获取验证码</span>
							</div>
							<div class="right">
								<input type="text" placeholder="请输入验证码" lay-verify="required" id="verifyCode" name="verifyCode">
							</div>
						</div>
						<div class="footer">
							<div class="firm" id="firm">取消</div>
							<!--<div class="save" id="save">保存</div>-->
							<button class="layui-btn" lay-submit lay-filter="saveBankInfo">保存</button>
						</div>
					</li>
				</ul>
			</div>
			</form>
		</div>
		<div class="layui-tab-item">
			<div class="w-header">
				<div class="account">
					<p>账户余额：<em id="remainMoney">0.00</em>元</p>
				</div>
				<div class="w-number">
					<p>待审金额：<em id="toAuditMoney">0.00</em>元</p>
				</div>
			</div>
			<div class="w-content">
				<div class="s-left">
					<ul>
						<li>
							<p>提现金额：</p>
							<input type="text" onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')" id="drawMoney">
						</li>
						<li>
							<p>提现账户：</p>
							<div class="item-a">
								<p class="name" id="cardOwner1"></p>
								<p class="number" id="cardNo1"></p>
							</div>
						</li>
						<li>
							<div class="submit" id="withdrawButton">提现</div>
						</li>
					</ul>
				</div>
				<div class="s-right">
					<ul>
						<li>温馨提示：</li>
						<li>1.每笔提现金额不能少于200元</li>
						<li>2.请确保您的银行账号信息准确无误</li>
						<li>3.发票联系:微信12312313/QQ-1231313131313</li>
						<li>4.工作时间:周一至周五，09:00-18:30</li>
					</ul>
				</div>
			</div>
		</div>
		<div class="layui-tab-item">
			<form class="layui-form">
				<div class="layui-input-block" >
					<!--0(启用列表设置)1(空闲)2(适中)3(紧张)4(火爆)-->
					<input type="radio" lay-filter="alwaysStatus" name="alwaysStatus" value="0" title="启用阈值设置">
					<input type="radio" lay-filter="alwaysStatus" name="alwaysStatus" value="1" title="始终显示空闲" >
					<input type="radio" lay-filter="alwaysStatus" name="alwaysStatus" value="2" title="始终显示适中" >
					<input type="radio" lay-filter="alwaysStatus" name="alwaysStatus" value="3" title="始终显示紧张" >
					<input type="radio" lay-filter="alwaysStatus" name="alwaysStatus" value="4" title="始终显示火爆" >
				</div>
			</form>
			<div class="item-set">
				<table class="layui-table" lay-filter="threshold" id="threshold-list">
				</table>
			</div>
		</div>
		<div class="layui-tab-item">
			<form class="layui-form" action="">
				<div class="item-price">
					<ul>
						<li>
							<p class="item-left">营业时间:</p>
							<div class="item-content item-other" style="height:auto">
								<input name="businessTime" type="text" placeholder="请输入营业时间" class="layui-input">
							</div>
						</li>

						<li>
							<p class="item-left">门店图片：</p>
							<div class="item-content">
								<!--<span>暂无图片</span>-->
								<input type="hidden" name="merchantImg">
								<img src="" alt="" id="merchantImg">
							</div>
							<div class="item-right">
								<button type="button" class="layui-btn" id="merchantImgBut">
									<i class="layui-icon">&#xe67c;</i>上传图片
								</button>
							</div>
						</li>

						<li>
							<p class="item-left">门店介绍：</p>
							<div class="item-content item-other">
								<textarea name="introduction" placeholder="请输入门店介绍" class="layui-textarea"></textarea>
							<!--	<textarea name=""  cols="30" rows="10" placeholder="请输入门店介绍"></textarea>-->
							</div>
						</li>
						<li>
							<button class="layui-btn" lay-submit lay-filter="merchantForm">立即提交</button>
							<!--<div class="item-submit">提交</div>-->
						</li>
					</ul>
				</div>
			</form>
		</div>
		<div class="layui-tab-item">
			<form class="layui-form" action="">
				<div class="item-price">
					<ul>
						<li>
							<p class="item-left">海报图片：</p>
							<div class="item-content">
								<!--<span>暂无图片</span>-->
								<input type="hidden" name="posterImg">
								<img src="" alt="" id="specialOfferImg">
							</div>
							<div class="item-right">
								<button type="button" class="layui-btn" id="specialOfferImgBut">
									<i class="layui-icon">&#xe67c;</i>上传图片
								</button>
							</div>
						</li>
						<li>
							<p class="item-left">说明：</p>
							<div class="item-content item-other">
								<textarea name="description" placeholder="请输入活动说明" class="layui-textarea"></textarea>
								<!--<textarea name="" id="" cols="30" rows="10" placeholder="请输入活动说明"></textarea>-->
							</div>
						</li>
						<li>
							<button class="layui-btn" lay-submit lay-filter="sepecialOfferForm">立即提交</button>
							<!--<div class="item-submit">提交</div>-->
						</li>
					</ul>
				</div>
			</form>
		</div>
		<div class="layui-tab-item">
			<table class="layui-table" id="evaluationList" lay-filter="evaluation"></table>
		</div>
		<div class="layui-tab-item">
			<table class="layui-table" id="wlist" lay-filter="wlist"></table>
		</div>
	</div>
</div>
<script type="text/javascript" src="js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="plugins/layui/layui.all.js"></script>
<script type="text/javascript" src="js/user/newsList.js"></script>
<script src="js/TimerButton.js"></script>
<script type="text/html" id="barDemo">
	<a class="layui-btn layui-btn-xs" lay-event="edit"><i class="iconfont icon-edit"></i>编辑</a>
	<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon"></i>删除</a>
</script>
<script type="text/javascript">
	$("#eduit").click(function(){
        $(".show").css("display","block");
        $(".add").css("display","none");
        $(".item-edit").css("display","block");
	})

	/**
	 * 取消
	 * **/
	$("#firm").click(function(){
        if($('.show').is(':hidden')){
            $(".add").css("display","block");
            $(".item-edit").css("display","none");
            $(".show").css("display","none");
		}else{
            $(".show").css("display","block");
            $(".add").css("display","none");
            $(".item-edit").css("display","none");
		}
	})
    /**
     * 添加银行卡
     * **/
    $("#add").bind("click",function(){

        $(".item-edit").show(1000);
    })

    /**
     * 保存银行卡
     * **/
    $("#save").click(function(){
        if($("#bank").val()==''){
        layer.msg('请选择开户银行');
        return;
		}else if($("#bankNumber").val() == ''){
			layer.msg('请输入银行卡号码');
			return;
		}else if($("#verifyCode").val()==''){
			layer.msg('请输入验证码');
			return;
		}
		$(".show").show(1000);
    })

    /**
	 *上传图片
     */
    layui.use('upload', function(){
        var upload = layui.upload;
        var uploadInst = upload.render({
            elem: '#specialOfferImgBut'
            ,url: '/specialOffer/upload/'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#specialOfferImg').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code==2000){
                    //上传成功
                    layer.msg('上传成功');
                    $("input[name='posterImg']").val(res.data);
                } else{
                    return   layer.msg('上传失败');
                }
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });

        var uploadInst2 = upload.render({
            elem: '#merchantImgBut'
            ,url: '/merchants/upload/'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#merchantImg').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                //如果上传失败
                if(res.code==2000){
                    //上传成功
                    layer.msg('上传成功');
                    $("input[name='merchantImg']").val(res.data);
                } else{
                    return   layer.msg('上传失败');
                }
            }
            ,error: function(){
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
        });
    });


    /**
     * 选项卡
     * **/
    layui.use('element', function(){
        var element = layui.element;
    });
    layui.use('form', function() {
        var form = layui.form;
        form.on("submit(sepecialOfferForm)",function(data){
            var datas=data.field;
            console.log(datas);
            var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            $.ajax({
                type: "POST",
                url:"/specialOffer/set",
                data:JSON.stringify(datas),// 序列化表单值
                contentType:"application/json",
                success: function(res) {
                    if(res.code==2000){
                        top.layer.close(index);
                        top.layer.msg("修改成功！");
                    }else{
                        top.layer.msg(res.msg);
                    }

                } ,
                error: function(request) {
                    alert("Connection error");
                }
            });
            return false;
        });
        form.on("submit(merchantForm)",function(data){
            var datas=data.field;
            console.log(datas);
            var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            $.ajax({
                type: "POST",
                url:"/merchants/saveIntroduction",
                data:{merchantImg:datas.merchantImg,introduction:datas.introduction,businessTime:datas.businessTime},
               // contentType:"application/json",
                success: function(res) {
                    if(res.code==2000){
                        top.layer.close(index);
                        top.layer.msg("修改成功！");
                    }else{
                        top.layer.msg(res.msg);
                    }
                } ,
                error: function(request) {
                    alert("Connection error");
                }
            });
            return false;
        });

        form.on("submit(saveBankInfo)",function(data){
            var datas=data.field;
            console.log(datas);
            var index = top.layer.msg('数据提交中，请稍候',{icon: 16,time:false,shade:0.8});
            $.ajax({
                type: "POST",
                url:"/merchants/bindBankInfo",
                data:JSON.stringify(datas),// 序列化表单值
                //   dataType: "json",
                contentType:"application/json",
                success: function(res) {
                    if(res.code==2000){
                        top.layer.close(index);
                        $(".item-edit").css("display","none")
                        top.layer.msg("保存成功！");
                        initBankCardInfo()
                    }else{
                        top.layer.msg(res.msg);
					}
                } ,
                error: function(request) {
                    alert("请求错误");
                }
            });
            return false;
        });

		initBankCardInfo();
        initSpecialOffer();
        initIntroduction();
        function initBankCardInfo() {
            $.ajax({
                url:'/merchants/isBindBankInfo',
                method:"GET",
				async:false,
                success:function (data) {
                    if(data.code==2000){
                        $("#cardOwner").html(data.data.rcvAcctName);
                        $("#cardNo").html(data.data.rcvBankNo);
                        $("#cardOwner1").html(data.data.rcvAcctName);
                        $("#cardNo1").html(data.data.rcvBankNo);
                        $(".show").css("display","block");
					}else {
                        $(".add").css("display","block");
					}
                }
            });
        }
        function initSpecialOffer() {
            $.ajax({
                url:'/specialOffer/get',
                method:"GET",
                async:false,
                success:function (data) {
                    var spec = data.data;
                    $("input[name='posterImg']").val(spec.posterImg);
                    $("#specialOfferImg").attr("src",spec.posterImg);
                    $("textarea[name='description']").text(spec.description);
                    form.render();//重新绘制表单，让修改生效
                }
            });
        }
        function initIntroduction() {
            $.ajax({
                url:'/merchants/getIntroduction',
                method:"GET",
                async:false,
                success:function (data) {
                    var mer = data.data;
                    $("input[name='merchantImg']").val(mer.merchantImg);
                    $("#merchantImg").attr("src",mer.merchantImg);
                    $("textarea[name='introduction']").text(mer.introduction);
                    $("input[name='businessTime']").val(mer.businessTime);

                    form.render();//重新绘制表单，让修改生效
                }
            });
        }
    })

    layui.config({
        base : "/js/admin/"
    }).extend({
        $tool: 'tool'
    }).use(['table','$tool','form'],function () {
		var table=layui.table,
			$tool=layui.$tool,
			form=layui.form;
        var tabledata = [];
		initThreshold();
		function initThreshold() {
            $.ajax({
                type : "GET",
                url: '/subscribeConfig/getThreshold',
                dataType:'json',
                async:false,
                success: function(data){
                    var config=data.data;
                   var obj=new Object();
                   obj.degreeHot=config.degreeHot;
                    obj.degreeTense=config.degreeTense;
                    obj.degreeModerate=config.degreeModerate;
                    obj.degreeLeisure=config.degreeLeisure;
                    $(":radio[name='alwaysStatus'][value='" + config.alwaysStatus + "']").attr("checked", true);
                    tabledata.push(obj);
                    form.render();
                }
            });

        }

        form.on('radio(alwaysStatus)', function(data){
            console.log(data.elem); //得到radio原始DOM对象
            console.log(data.value); //被点击的radio的value值
            $.ajax({
                type : "POST",
                url: '/subscribeConfig/setAlwaysStatus',
                data:{status:data.value},
                async:false,
                success: function(data){
                    layer.msg(data.msg);
                }
            });

        });
        table.render({
            elem: '#threshold-list'
            ,data: tabledata
            ,page: false //开启分页
            ,cols: [[ //表头
                {field: 'degreeLeisure', title: '空闲',edit: 'text'}
                ,{field: 'degreeModerate', title: '适中', edit: 'text'}
                ,{field: 'degreeTense', title: '紧张',edit: 'text'}
                ,{field: 'degreeHot', title: '火爆',edit: 'text'}

            ]]
			,height:500
        });
        //监听单元格编辑
        table.on('edit(threshold)', function(obj){
            var value = obj.value //得到修改后的值
                ,data = obj.data //得到所在行所有键值
                ,field = obj.field; //得到字段
            var d;
			var oldValue=$(this).prev().text();

           // tabledata[data.LAY_TABLE_INDEX] = data;
            $.ajax({
                type : "POST",
                url: '/subscribeConfig/setThreshold',
               	data:{type:field,value:value},
                async:false,
                success: function(data){
                     layer.msg(data.msg);
                     if(data.code==4000){
                         eval("tabledata[0]."+field+"="+oldValue);
                       //  tabledata[0].degreeHot = oldValue;
                       // obj.update({degreeHot:'yyy'});
                         table.reload('threshold-list',{
                             data : tabledata
                         });

					 }
                }
            });

        });

        var tableIns=table.render({
            elem: '#wlist'
            ,url: '/enchashment/applyEnchashmentList'
            ,cols: [[
                {checkbox: true}
//                ,{field:'id', title: 'ID'}
                ,{field:'enchashmentName', title: '客户姓名'}
                ,{field:'orderNumber', title: '订单号'}
                ,{field:'residueAmount', title: '剩余金额'}
                ,{field:'sum', title: '交易金额'}
                ,{field:'createTime', title: '创建时间',
                    templet:function(d){
                        if(d.createTime!=null){
                            return $tool.formatTime(d.createTime);
                    	}
				}}
                ,{field:'status', title: '交易状态',
                    templet:function(d){
                        if(d.status==-1){
                            return "审核不通过"
                        }else if(d.status==0){
                            return "未审核"
                        }else if(d.status==1){
                            return "审核通过"
                        }
				}}
            ]]
            ,id: 'testReload'
            ,page: true
        });
        table.render({
            elem: '#evaluationList'
            ,url: '/evaluation'
            ,cols: [[
                {checkbox: true}
                ,{field:'id', title: 'ID'}
                ,{field:'name', title: '客户姓名'}
                ,{field:'phone', title: '手机号码'}
                ,{field:'img1', title: '留言图片1', templet:
                        function(d){
                            var img = '<img style="width: 80px;height: 80px;" src="'+d.img1+'" alt="">';
                            return img;

                        }
                }
                ,{field:'img1', title: '留言图片链接', templet:
                        function(d){
                            var img = '<a href="'+d.img1+'">留言图片链接1</a>';
                            return img;

                        }
                }
                ,{field:'img2', title: '留言图片2',templet:
                        function(d){
                            var img = '<img style="width: 80px;height: 80px;"  src="'+d.img2+'" alt="">';
                            return img;
                        }},
                {field:'img1', title: '留言图片链接', templet:
                        function(d){
                            var img = '<a href="'+d.img2+'">留言图片链接2</a>';
                            return img;

                        }
                }
                ,{field:'img3', title: '留言图片3',width:'10%',height:'20', templet:
                        function(d){
                            var img = '<img style="width: 80px;height: 80px;" src="'+d.img3+'" alt="">';
                            return img;
                        }},
                {field:'img1', title: '留言图片链接', templet:
                        function(d){
                            var img = '<a href="'+d.img3+'">留言图片链接3</a>';
                            return img;

                        }
                }
                ,{field:'message', title: '留言'}
                ,{field:'createTime', title: '创建时间',
                    templet:function(d){
                        if(d.createTime!=null){
                            return $tool.formatTime(d.createTime);
                        }
                    }}
            ]]
//            ,id: 'testReload'
            ,page: true
        });

        getAllProvince();
        getPhoneForCurrentMerchant();
        getWalletForCurrentMerchant();
        function getAllProvince() {
            $.ajax({
                type : "GET",
                url: '/areas/getAllProvinces',
                dataType:'json',
                async:false,
                success: function(data){
                    var list=data.data;
                    var html='';
                    for(var i=0;i<list.length;i++){
                        html += "<option value='"+list[i].provinceCode+"'>"+list[i].province+"</option>"
                    }
                    $("#province").append(html);

                   /* $("#province").change(function(){
                        getAllCitysByProvinceCode( $(this).children('option:selected').val());
                    });*/
                    form.render();

                }
            });
        }

        form.on('select(province)', function(data){
            getAllCitysByProvinceCode(data.value);
        });

        form.on('select(city)', function(data){
			getAllDistrictsByCityCode(data.value);
        });
        form.on('select(district)', function(data){
            getAllBanksByDistrictCode(data.value);
        });
        function getSendCode() {
            var TIME_COUNT =120;
            var timer = setInterval(function(){
                if(TIME_COUNT > 0 && TIME_COUNT <= TIME_COUNT) {
                    TIME_COUNT--;
                    $("#code").html(TIME_COUNT)
                } else {
                    $("#code").html("发送验证码")
                    clearInterval(this.timer);
                    this.timer = null;
                }
            }, 1000)
        };

        function getAllCitysByProvinceCode(provinceCode) {
            $.ajax({
                type : "GET",
                url: '/areas/getAllCitys/'+provinceCode,
                dataType:'json',
                async:false,
                success: function(data){
                    var list=data.data;
                    var html='<option value="">--请选择区域--</option>';
                    for(var i=0;i<list.length;i++){
                        html += "<option value='"+list[i].cityCode+"'>"+list[i].city+"</option>"
                    }
                    $("#city").empty();
                    $("#city").append(html);
                    $("#district").empty();
                    $("#district").append("<option value=''>--请选择区域--</option>");
                    $("#bank").empty();
                    $("#bank").append("<option value=''>--请选择开户银行--</option>");
                  /*  $("#city").change(function(){
                        getAllDistrictsByCityCode( $(this).children('option:selected').val());
                    });*/
                    form.render();
                }
            });
        }

        function getAllDistrictsByCityCode(cityCode) {
            $.ajax({
                type : "GET",
                url: '/areas/getAllDistricts/'+cityCode,
                dataType:'json',
                async:false,
                success: function(data){
                    var list=data.data;
                    var html='<option value="">--请选择区域--</option>';
                    for(var i=0;i<list.length;i++){
                        html += "<option value='"+list[i].districtCode+"'>"+list[i].district+"</option>"
                    }
                    $("#district").empty();
                    $("#district").append(html);
                    $("#bank").empty();
                    $("#bank").append("<option value=''>--请选择开户银行--</option>");
                  /*  $("#district").change(function(){
                        getAllBanksByDistrictCode( $(this).children('option:selected').val());
                    });*/
                    form.render();

                }
            });
        }

        function getAllBanksByDistrictCode(districtCode) {
            $.ajax({
                type : "GET",
                url: '/areas/getAllBanks/'+districtCode,
                dataType:'json',
                async:false,
                success: function(data){
                    var list=data.data;
                    var html='<option value="">--请选择开户银行--</option>';
                    for(var i=0;i<list.length;i++){
                        html += "<option value='"+list[i].directBankCode+"'>"+list[i].bankName+"</option>"
                    }
                    $("#bank").empty();
                    $("#bank").append(html);
					form.render();

                }
            });
        }

        function getPhoneForCurrentMerchant() {
            $.ajax({
                type : "GET",
                url: '/merchants/getPhoneForCurrentMerchant',
                dataType:'json',
                async:false,
                success: function(data){
                    var phone=data.data;
                    $("#phone").text(phone);
                }
            });
        }

        function getWalletForCurrentMerchant() {
            $.ajax({
                type : "GET",
                url: '/merchants/getWalletForCurrentMerchant',
                dataType:'json',
                async:false,
                success: function(data){
                    var wallet=data.data;
                    localStorage.setItem("yhlMerchantId",wallet.merchantId);
                    $("#remainMoney").text(wallet.walletBalance);
                    $("#toAuditMoney").text(wallet.waitAuditSum);
                }
            });
        }

        $("#withdrawButton").click(function () {
			var drawMoney=$("#drawMoney").val();
			var merchantId=localStorage.getItem("yhlMerchantId");
			/*if(drawMoney<200){
			    layer.msg('单次提现不得少于200元');
			    return;
			}*/
            var obj={};
			obj.Amount=drawMoney;
			obj.merchantId=merchantId;
            $.ajax({
                type: "POST",
                url:"/enchashment/applyEnchashment",
                data:JSON.stringify(obj),// 序列化表单值
                contentType:"application/json",
                success: function(res) {
                    if(res.code==2000){
                     //   top.layer.close(index);
                       	layer.msg(res.msg);
                       	$("#drawMoney").val("0")
                        getWalletForCurrentMerchant();
                        table.render({
                            elem: '#wlist'
                            ,url: '/enchashment/applyEnchashmentList'
                            ,cols: [[
                                {checkbox: true}
//                ,{field:'id', title: 'ID'}
                                ,{field:'enchashmentName', title: '客户姓名'}
                                ,{field:'orderNumber', title: '订单号'}
                                ,{field:'residueAmount', title: '剩余金额'}
                                ,{field:'sum', title: '交易金额'}
                                ,{field:'createTime', title: '创建时间',
                                    templet:function(d){
                                        if(d.createTime!=null){
                                            return $tool.formatTime(d.createTime);
                                        }
                                    }}
                                ,{field:'status', title: '交易状态',
                                    templet:function(d){
                                        if(d.status==-1){
                                            return "审核不通过"
                                        }else if(d.status==0){
                                            return "未审核"
                                        }else if(d.status==1){
                                            return "审核通过"
                                        }
                                    }}
                            ]]
                            ,id: 'testReload'
                            ,page: true
                        });
                    }else{
                        layer.msg(res.msg);
                    }

                } ,
                error: function(request) {
                    alert("Connection error");
                }
            });
        })


        /**
         *倒计时
         */
        var btn = $("#j_getVerifyCode");
        timerButton.verify("#j_getVerifyCode", {
            time: 60,//倒计时时间
            event: "click",//事件触发方式
            //执行条件，可以是function也可以是Boolean值，如果是函数则需返回true才会执行
            condition: function () {
                var switchs=false;
                var phone=$("#phone").text();
                var phoneReg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1})|(17[0-9]{1}))+\d{8})$/,
                    flag = phoneReg.test(phone);
                if(!flag){
                    layer.msg("请输入合法的手机号码");
                    switchs=false;
                    return switchs;
                }
                $.ajax({
                    url: "/merchants/getBankInfoVerifyCode",
                    data: {
                        "phone":phone
                    },
                    type: "POST",
                    async: false,
                    success: function (data) {
                        if(data.code==2000){
                            layer.msg("验证码发送成功");
                            switchs=true;
                        }else{
                            layer.msg("验证码发送失败");
                            switchs=false;
                        }
                    },
                    error:function (data){
                        console.log(data);
                    }
                });
                return switchs;
            },
            unableClass: "disabled",//按钮不能使用时的class
            runningText: " s后重新获取",//计时正在进行中时按钮显示的文字
            timeUpText: "重新获取",//时间到了时按钮显示的文字
            progress: function (time) {//计时正在进行中时的回调
                btn.attr("disabled",true);
                btn.html(time + " s后重新获取");
                console.log(this);//这里的this指向按钮
                console.log(this.timedown);//这个timedown就是计时器
            },
            timeUp: function (time) {//计时结束时执行的回调
                btn.attr("disabled",false);
                btn.html("重新获取");
                console.log("时间到了！");
                console.log(this);//这里的this指向按钮
            },
            abort: function () {//中断计时
                btn.html("重新获取");
                console.log("我被中断了！");
                console.log(this);//这里的this指向按钮
            },
            eventFn: function () {//事件执行后的回调
                console.log("执行了");
                console.log(this);//这里的this指向按钮
            }
        });
        //中断计时
        $("#abort_btn").on("click", function (){
            document.getElementById("j_getVerifyCode").timedown.abort();
        });


    });


</script>
</body>
</html>